using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using JGSY.CMS.LowCode.Platform.Domain.Entities;
using JGSY.CMS.LowCode.Platform.Domain.Enums;

namespace JGSY.CMS.LowCode.Platform.Domain.Interfaces
{
    /// <summary>
    /// 工作流任务仓储接口
    /// </summary>
    public interface IWorkflowTaskRepository : IRepository<WorkflowTask>
    {
        /// <summary>
        /// 根据实例ID获取任务列表
        /// </summary>
        /// <param name="instanceId">实例ID</param>
        /// <returns>任务列表</returns>
        Task<List<WorkflowTask>> GetByInstanceIdAsync(long instanceId);

        /// <summary>
        /// 根据分配人获取任务列表
        /// </summary>
        /// <param name="assignedTo">分配人ID</param>
        /// <returns>任务列表</returns>
        Task<List<WorkflowTask>> GetByAssigneeAsync(long assignedTo);

        /// <summary>
        /// 根据状态获取任务列表
        /// </summary>
        /// <param name="status">状态</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页大小</param>
        /// <returns>任务列表</returns>
        Task<IEnumerable<WorkflowTask>> GetByStatusAsync(WorkflowTaskStatus status, int pageIndex = 1, int pageSize = 20);

        /// <summary>
        /// 获取待处理任务列表
        /// </summary>
        /// <param name="assignedTo">分配人ID</param>
        /// <returns>待处理任务列表</returns>
        Task<List<WorkflowTask>> GetPendingTasksAsync(long assignedTo);

        /// <summary>
        /// 获取超时任务列表
        /// </summary>
        /// <returns>超时任务列表</returns>
        Task<List<WorkflowTask>> GetOverdueTasksAsync();

        /// <summary>
        /// 获取任务统计信息
        /// </summary>
        /// <param name="assignedTo">分配人ID</param>
        /// <returns>统计信息</returns>
        Task<Dictionary<string, int>> GetTaskStatisticsAsync(long assignedTo);

        /// <summary>
        /// 批量分配任务
        /// </summary>
        /// <param name="taskIds">任务ID列表</param>
        /// <param name="assignedTo">分配给</param>
        /// <returns>是否成功</returns>
        Task<bool> BatchAssignTasksAsync(List<long> taskIds, long assignedTo);

        /// <summary>
        /// 自动分配任务
        /// </summary>
        /// <param name="instanceId">实例ID</param>
        /// <param name="taskType">任务类型</param>
        /// <returns>分配的任务</returns>
        Task<WorkflowTask?> AutoAssignTaskAsync(long instanceId, string taskType);
    }
}
